SVG to PNG

Installation

$ composer require meyfa/php-svg

Getting Started

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
require '../vendor/autoload.php';

use SVG\SVGImage;

use SVG\Nodes\Shapes\SVGRect;

$svg = file_get_contents("d:/1.svg");

$svg = str_replace('fill="#2c2c2c"','fill="#e21010"',$svg);

$image = SVGImage::fromString($svg);

$rasterImage = $image->toRasterImage(200, 200);

header('Content-Type: image/png');

imagepng($rasterImage,'d:/1.png');
关注作者公众号,获取更多资源!
赏作者一杯咖啡~